import { ref, onMounted, watch, nextTick } from 'vue';

import { get_article_list } from '@/api/index'

let skip = ref(0)
let limit = 10
let articleList = ref([])
export default function (cate_id,status) {
	
	
	function get_article(cate_id){
		
		get_article_list({
		    skip:skip.value,
		    limit,
		    cate_id
		}).then(res => {
		
		    articleList.value.push(...res.data)
			
			if(articleList.value.length>=res.count){
				
				status.value = 'nomore'
			}else{
				
				status.value = 'more'
			}
			
			// 现在去获取真实的dom  拿不到
			//  
			
		//       nextTick(function(){
				 //  console.log(
				 //  document.querySelector('.article_list').innerHTML)
			  // })
		
		})
		
	}
	
	
	
    onMounted(function () {


        watch(cate_id, (n) => {

            // console.log(n._id)

                get_article(n._id)
        })

    })

    return {
        skip,
        limit,
        articleList,
		get_article
    }


}